package com.chenfan.mcn.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chenfan.mcn.model.BusinessCommission;
import com.chenfan.mcn.model.dto.BusinessCommissionBatchSaveDTO;
import com.chenfan.mcn.model.BusinessCommissionDetail;
import com.chenfan.mcn.model.McnPage;
import com.chenfan.mcn.model.dto.*;
import com.chenfan.mcn.model.vo.*;
import com.chenfan.mcn.model.common.PageInfo;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 商务提成 服务类
 * </p>
 *
 * @author lizhejin
 * @since 2021-06-07
 */
public interface BusinessCommissionService extends IService<BusinessCommission> {

    /**
     * 商务提成列表
     * @param page
     * @param businessCommissionDTO
     * @return
     */
    Page<BusinessCommissionVO> getList(McnPage<BusinessCommissionVO> page, BusinessCommissionDTO businessCommissionDTO);

    /**
     * 季度编号下拉选项
     *
     * @return List
     */
    List<String> getQuarterCode();

    /**
     * 详情
     *
     * @param page {@link McnPage}
     * @param dto  {@link Long}
     * @return {@link BusinessCommissionInfo}
     */
    BusinessCommissionInfo info(McnPage<BusinessCommissionDetail> page, BusinessInfoQueryDTO dto);

    /**
     * 详情导出excel
     *
     * @param id       商务提成id
     * @param response {@link HttpServletResponse}
     * @throws Exception 抛异常
     */
    void exportExcel(Long id, HttpServletResponse response) throws Exception;


    /**
     * 组装导出数据
     * @param exportList
     */
    void assembleExportData(List<BusinessCommissionDetailVoV2> exportList);

    /**
     * 新建商务提成
     *
     * @param addDTO {@link BusinessCommissionAddDTO}
     */
    Long saveBusinessCommission(BusinessCommissionAddDTO addDTO);

    /**
     * 修改状态
     *
     * @param id             提成id
     * @param businessStatus 状态
     */
    void changeStatus(Long id, Integer businessStatus);

    /**
     * 商务弹窗
     *
     * @param page            分页
     * @param businessInfoDTO 查询条件
     * @return {@link BusinessInfo}
     */
    BusinessInfo businessInfo(McnPage<BusinessCommissionDetail> page, BusinessInfoDTO businessInfoDTO);

    /**
     * 商务弹窗导出
     *
     * @param businessInfoDTO 查询条件
     * @param response        {@link HttpServletResponse}
     * @throws Exception 抛异常
     */
    void exportBusinessInfo(BusinessInfoDTO businessInfoDTO, HttpServletResponse response) throws Exception;

    /**
     * 商务弹窗 确认提成
     *
     * @param id     提成id
     * @param userId 用户id
     * @param status 状态(1-商务提成，2-部门提成)
     */
    void personalConfirmCommission(Long id, Long userId, Integer status);

    /**
     * 部门负责人弹窗
     *
     * @param page              分页
     * @param departmentInfoDTO 查询条件
     * @return {@link DepartmentInfo}
     */
    DepartmentInfo departmentInfo(McnPage<BusinessCommissionDetail> page, DepartmentInfoDTO departmentInfoDTO);

    /**
     * 部门负责人弹窗导出
     *
     * @param departmentInfoDTO 查询条件
     * @param response          {@link HttpServletResponse}
     * @throws Exception 抛异常
     */
    void exportDepartInfo(DepartmentInfoDTO departmentInfoDTO, HttpServletResponse response) throws Exception;

    /**
     * 提成单详情-基本信息
     *
     * @param id 提成单id
     * @return BusinessCommissionInfoVO
     */
    BusinessCommissionInfoVO getShortDetail(Long id);

    /**
     * 提成单详情-分页列表
     *
     * @param businessCommissionDetailPageDTO {@link BusinessCommissionDetailPageDTO}
     * @return PageInfo<BusinessCommissionDetail> {@link BusinessCommissionDetail}
     */
    PageInfo<BusinessCommissionDetail> getDetailPage(BusinessCommissionDetailPageDTO businessCommissionDetailPageDTO);

    /**
     * 提成单详情-确认详情
     *
     * @param businessCheckDetailPageDTO {@link BusinessCheckDetailPageDTO}
     * @return PageInfo<BusinessCheckDetailVO> {@link BusinessCheckDetailVO}
     */
    BusinessConfirmationDetails getCheckDetailPage(BusinessCheckDetailPageDTO businessCheckDetailPageDTO);

    /**
     * 发送提成单
     *
     * @param id 提成单id
     */
    void sendBusinessCommission(Long id);

    /**
     * 导出商务提成单-分页列表
     *
     * @param businessCommissionDetailPageDTO {@link BusinessCommissionDetailPageDTO}
     * @param response                        {@link HttpServletResponse}
     */
    void exportDetailPage(BusinessCommissionDetailPageDTO businessCommissionDetailPageDTO, HttpServletResponse response);

    /**
     * 修改提成单
     * @param dto
     * @return
     */
    boolean updateData(BusinessCommissionAddDTO dto);

    /**
     * 批量删除(编辑)
     *
     * @param ids {@link List<Long>}
     * @return {@link Boolean}
     */
    boolean batchDeleteDetail(List<Long> ids);

    /**
     * 编辑列表
     *
     * @param dto    传参
     * @return {@link Integer}
     */
    Object editDetail(BusinessCommissionUpdateDTO dto);

    /**
     * 保存商务提成明细
     * @param businessCommission
     * @param detailList
     */
    // void saveBusinessDetails(BusinessCommission businessCommission, List<String> incomeCodes, List<BusinessCommissionDetail> detailList);
    void saveBusinessDetails(BusinessCommission businessCommission,List<BusinessCommissionDetail> detailList);


    /**
     *导入批量保存明细
     * @param businessCommission
     * @param list
     * @return
     */
    String importBatchSave(BusinessCommission businessCommission, List<BusinessCommissionBatchSaveDTO> list);

    /**
     * 导入批量删除明细
     * @param businessCommission
     * @param inputList
     * @return
     */
    String importBatchDelete(BusinessCommission businessCommission, List<BusinessCommissionBatchDeleteDTO> inputList);

    /**
     * 下载失败原因
     *
     * @param response {@link HttpServletResponse}
     * @param fileId
     */
    void excelDownload(HttpServletResponse response, String fileId);

}
